package main
 
import (
	"fmt"
	"net"
	"sync"
)
 
func scanPort(host string, port int, wg *sync.WaitGroup) {
	defer wg.Done()
 
	address := fmt.Sprintf("%s:%d", host, port)
	conn, err := net.Dial("tcp", address)
	if err == nil {
		fmt.Printf("Port %d on %s is open\n", port, host)
		conn.Close()
	}
}
 
func main() {
	host := "127.0.0.1"
	ports := []int{80, 443, 8080, 8888}
 
	var wg sync.WaitGroup
	wg.Add(len(ports))
 
	for _, port := range ports {
		go scanPort(host, port, &wg)
	}
 
	wg.Wait()
}